package com.vertexnet.realestatenet.model.bean;

// Generated May 22, 2012 8:11:57 AM by Hibernate Tools 3.4.0.CR1

import static javax.persistence.GenerationType.IDENTITY;

import java.math.BigDecimal;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;


/**
 * Layout generated by hbm2java
 */
@Entity
@Table(name = "layout", catalog = "real_estate_net")
public class Layout implements java.io.Serializable {

	private static final long serialVersionUID = 1L;
	private Integer layoutId;
	private String address;
	private String name;
	private int numSites;
	private BigDecimal totalSquareFeet;
	private Set<PaymentPlan> paymentPlans = new HashSet<PaymentPlan>(0);
	private Set<Site> sites = new HashSet<Site>(0);

	public Layout() {
	}

	public Layout(String name, int numSites) {
		this.name = name;
		this.numSites = numSites;
	}

	public Layout(String address, String name, int numSites, BigDecimal totalSquareFeet, Set<PaymentPlan> paymentPlans, Set<Site> sites) {
		this.address = address;
		this.name = name;
		this.numSites = numSites;
		this.totalSquareFeet = totalSquareFeet;
		this.paymentPlans = paymentPlans;
		this.sites = sites;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "layout_id", unique = true, nullable = false)
	public Integer getLayoutId() {
		return this.layoutId;
	}

	public void setLayoutId(Integer layoutId) {
		this.layoutId = layoutId;
	}

	@Column(name = "address")
	public String getAddress() {
		return this.address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	@Column(name = "name", nullable = false, length = 25)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "num_sites", nullable = false)
	public int getNumSites() {
		return this.numSites;
	}

	public void setNumSites(int numSites) {
		this.numSites = numSites;
	}

	@Column(name = "total_square_feet")
	public BigDecimal getTotalSquareFeet() {
		return this.totalSquareFeet;
	}

	public void setTotalSquareFeet(BigDecimal totalSquareFeet) {
		this.totalSquareFeet = totalSquareFeet;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "layout", orphanRemoval=true)
	@NotFound(action = NotFoundAction.IGNORE)
	public Set<PaymentPlan> getPaymentPlans() {
		return this.paymentPlans;
	}

	public void setPaymentPlans(Set<PaymentPlan> paymentPlans) {
		this.paymentPlans = paymentPlans;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "layout")
	@NotFound(action = NotFoundAction.IGNORE)
	public Set<Site> getSites() {
		return this.sites;
	}

	public void setSites(Set<Site> sites) {
		this.sites = sites;
	}

	@Override
	public String toString() {
		return name;
	}

	@Override
	public boolean equals(Object obj) {
		if(obj instanceof Layout) {
			Layout layout = (Layout) obj;
			return new EqualsBuilder()
			.append(this.layoutId, layout.layoutId)
			.append(this.address, layout.address)
			.append(this.name, layout.name)
			.append(this.numSites, layout.numSites)
			.append(this.totalSquareFeet, layout.totalSquareFeet)
			.isEquals();
		}
		return false;
	}

	@Override
	public int hashCode() {
		return new HashCodeBuilder()
		.append(this.layoutId)
		.append(this.address)
		.append(this.name)
		.append(this.numSites)
		.append(this.totalSquareFeet)
		.toHashCode();
	}
}
